package com.fangque.kepp.framework.config.handle;

import com.fangque.kepp.framework.enums.ResultEnum;
import com.fangque.kepp.framework.result.ResultBean;
import com.fangque.kepp.framework.util.ResponseUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Lan
 * @date 2019/4/9 10:11
 * @description 权限认证异常处理器
 */
public class AuthEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException {
        ResponseUtil.write(response, ResultBean.error(ResultEnum.TOKEN_IS_NOT_VALID));
    }
}
